//
//  WYProfessionSectionView.m
//  Boss
//
//  Created by admin on 2018/7/5.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYProfessionSectionView.h"
@interface WYProfessionSectionView()
@property (nonatomic,strong) UILabel *nameLabel;
@property (nonatomic,strong) UILabel *subNameLabel;
@property (nonatomic,assign)NSUInteger section ;
@end
@implementation WYProfessionSectionView
+(instancetype)headFootViewTableView:(UITableView *)tableView section:(NSInteger)section
{
    static NSString * Head = @"h";
    WYProfessionSectionView * headerFooterView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:Head];
    if (headerFooterView == nil)
    {
        headerFooterView = [[WYProfessionSectionView alloc] initWithReuseIdentifier:Head withSection:section];
    }
    
    return headerFooterView;
}
-(id)initWithReuseIdentifier:(NSString *)reuseIdentifier withSection:(NSInteger)section
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]){
        self.section = section;
        [self createSubViews];
    }
    return self;
}
-(void)createSubViews
{
    
    UILabel *nameLabel = [[UILabel  alloc]init];
    self.nameLabel = nameLabel;
    [self addSubview:nameLabel];
    
    [nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(16);
        make.centerY.mas_equalTo(self);
    }];
    nameLabel.font = [UIFont  systemFontOfSize:14];
    nameLabel.textColor = [UIColor hexStringToColor:@"#222222" alpha:1.0];
    
    
    
    
    
    UILabel *subNameLabel = [[UILabel alloc]init];
    self.subNameLabel = subNameLabel;
    [self addSubview:subNameLabel];
    
    [subNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(nameLabel.mas_right).offset(16);
        make.centerY.mas_equalTo(self);
    }];
    
    subNameLabel.font = kFontSystemBIgger2(12);
    subNameLabel.textColor = [UIColor hexStringToColor:@"#999999" alpha:1.0];
    
    UIButton *button = [[UIButton alloc]init];
    [self addSubview:button];
    
    [button mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.top.bottom.mas_equalTo(0);
    }];
    [button addTarget:self action:@selector(didSection:) forControlEvents:(UIControlEventTouchUpInside)];
    
}
-(void)didSection:(UIButton *)btn
{
    self.model.isOpen = !self.model.isOpen;
    if ([self.delegate respondsToSelector:@selector(reloadTableView:)]) {
        [self.delegate reloadTableView:self.section];
    }
}





-(void)setModel:(WYProfession *)model
{
    _model = model;
    self.nameLabel.text = model.name;
    self.subNameLabel.text = model.describe;
    
    
    
    
    
}




@end
